#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>


using namespace std;
void string_cont(){
    //几种赋值方式
    string str="zheshichushihuadestring";
    string str_char="zheshichardestring";
    string str1=string();

    string str2=string(str);
    cout<<"before "<<str2<<endl;
    str2="after";
    cout<<"after "<<str2<<" "<<str<<endl;//这是重载的const string & str函数
    

    // string str3=string(const char *str_char);
    cout<<str1;

    //基本赋值
    string assign_str;
    str.assign("after assign");
    cout<<str<<endl;

    //存取字符操作
    cout<<str[2];
    cout<<endl<<str.at(2)<<endl;

}
 void string_plus()
 {
     //普通字符串
     string str ="this is normal string";
     //指针字符串
     string * str_point= &str;
     //char类型的字符串
     char *str_char="this is a string of char type";
     
     string plused="zhe shi yige mei jia de ";
     plused=plused+*str_point;//看doc文件,进行学习
     plused+= str_char;
     
     plused.clear();
     plused.append("zheshixindestring");
     cout<<plused<<endl;
 }

 void string_find(){
     //该函数用于string 的查找与替换;
     string plused="zhe shi yige mei jia de ";
     plused.clear();
     plused.append("zheshixindestring");

     //int numPos=plused.find("zzhe");//记住可以找
     //out<<numPos;
     
     
     int numPos=plused.rfind("ing");//反向查找,需要注意的是
                                   //反向查找,返回的首字母的第一个位置.
     cout<<numPos;


 }
int main()
{   
    //string_cont();
    // string_plus();
    string_find();
    //cout<<"test"<<endl;
}